/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */
package cn.hermit.data.xml.model;

import cn.hermit.data.xml.XML;
import cn.hermit.util.StringUtils;

/**
 * Java model of XML Text
 * 
 * @author Jack Gao (Chinese name : GAO JIANGUO, Email : linux.gjg@gmail.com)
 * @date 19 Jun, 2014
 */
public class XmlText extends XmlNode {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3168834487441700599L;

	Object content;

	XmlText() {
	}

	/**
	 * Get content of Text node.
	 * 
	 * @return 
	 * 		Content of Text node
	 */
	public Object getContent() {
		if (content == null) {
			content = XML.DEFAULT_NULL_VALUE;
		}
		return content;
	}

	/**
     * Serialize XML Text to XML string.
     */
	public String toString() {
		return this.getContent().toString();
	}

	@Override
	public String toFormatString(int depth, String newLineFeed,boolean newLineForTexts) {
		return StringUtils.tabs(depth) + toString();
	}
	
	@Override
	public boolean isDocument() {
		return false;
	}

	@Override
	public boolean isElement() {
		return false;
	}

	@Override
	public boolean isAttribute() {
		return false;
	}

	@Override
	public boolean isText() {
		return true;
	}
	
	@Override
	public boolean isPureText() {
		return true;
	}

	@Override
	public boolean isCdata() {
		return false;
	}

	@Override
	public boolean isComment() {
		return false;
	}

	@Override
	public boolean isHeader() {
		return false;
	}

	@Override
	public boolean isNameNode() {
		return false;
	}

}